package com.un.ebs.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.un.ebs.sys.domain.App;
import com.un.ebs.sys.dto.AppAddDto;
import com.un.ebs.sys.dto.AppUpdateDto;
import com.un.ebs.sys.mapper.AppMapper;
import com.un.ebs.sys.service.AppService;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author liubo
 * @since 2019-09-15
 */
@Service
public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements AppService {

    @Override
    public void add(AppAddDto req) {
        App obj = new App();
        obj.setName(req.getName());
        obj.setHomepageUrl(req.getHomepageUrl());
        obj.setHomepageMobileUrl(req.getHomepageMobileUrl());
        obj.setIsDelete(false);
        obj.insert();
    }

    @Override
    public void update(AppUpdateDto req) {
        App obj = getById(req.getId());
        obj.setName(req.getName());
        obj.setHomepageUrl(req.getHomepageUrl());
        obj.setHomepageMobileUrl(req.getHomepageMobileUrl());
        obj.updateById();
    }

    @Override
    public App queryById(String id) {
        return getBaseMapper().selectById(id);
    }

    @Override
    public void delete(String id) {
        getBaseMapper().deleteById(id);
    }

}